package com.lijing.subSets;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @Description TODO
 * @title: Subsets
 * @Author LiJing
 * @Date: 2021/4/78:06 上午
 * @Version 1.0
 */
public class Subsets {
    static List<LinkedList<Integer>> result = new ArrayList<>();
    static LinkedList<Integer> path = new LinkedList<>();

    public static void main(String[] args) {
        int[] nums = {1,2,3};
        backTracing(0,nums);
        System.out.println(result);
    }

    public static void backTracing(int startIndex, int[] nums){
        result.add(new LinkedList<>(path));
        if (path.size() >= nums.length){
            return;
        }

        for (int i = startIndex; i < nums.length; i++) {
            //处理当前节点
            path.addLast(nums[i]);
            backTracing(i+1,nums);
            path.removeLast();
        }
    }
}
